﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace PloobsEngine.SceneControl
{

    public class ColorCorrectionPostEffect : IPostEffect
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="contrast">0 a 1</param>
        public ColorCorrectionPostEffect(Color colorAdd ,float colorCorrect)
        {
            this.colorAdd = colorAdd.ToVector3(); ;
            this.colorCorrect = colorCorrect;

        }

        #region IPostEffect Members

        Effect effect = null;

        Vector3 colorAdd;

        public Vector3 ColorAdd
        {
            get { return colorAdd; }
            set { colorAdd = value; }
        }
        float colorCorrect;

        public float ColorCorrect
        {
            get { return colorCorrect; }
            set { colorCorrect = value; }
        }

        float colorToAddIntensity = 1;

        public float ColorToAddIntensity
        {
            get { return colorToAddIntensity; }
            set { colorToAddIntensity = value; }
        }

        public void Draw(IRenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Rectangle screenRec, IWorld world)
        {
            ///Draw a quad using the "effect", passing the CurrentImage as a Parameter            
            effect.Parameters["ColorCorrect"].SetValue(colorCorrect);
            effect.Parameters["ColorAdd"].SetValue(colorAdd);
            effect.Parameters["ColorToAddIntensity"].SetValue(colorToAddIntensity);
            
            rHelper.RenderTextureToFullScreenSpriteBatch(PrincipalConstants.CurrentImage, effect);
        }

        public void init(EngineStuff engine)
        {
            ///Load the asset
            effect = EngineStuff.InternalContentManager.GetAsset<Effect>("colorCorrection");
            //effect = EngineStuff.CustomContentManager.GetAsset<Effect>("..\\Content\\Effects\\colorCorrection");          
        }

        #endregion

    }
}
